package com.neo.repository;

import com.neo.model.TaskRecordResult;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.Update;

import java.time.LocalDateTime;
import java.util.List;

public interface InspectionRepo extends MongoRepository<TaskRecordResult, String> {

    TaskRecordResult findByLogId(long logId);

    void deleteSingleByLogId(long logId);


    @Update("{ '$set' : { 'approve' : ?1} }")
    int findAndUpdateApproveByLogId(long logId, int approve);

    @Query("{ 'executionTime' : { $gte : ?0, $lte : ?1 } }")
    List<TaskRecordResult> findByExecutionTimeBetween(LocalDateTime startDate, LocalDateTime endDate);

    @Query(value = "{}", fields = "{'logId': 1}")
    List<TaskRecordResult> findAllWithField();
}
